<template>
  <view>
		<home v-if="currentIndex === 0" :pullDown.sync="pullDown"></home>
		<message v-if="currentIndex === 1" :pullDown.sync="pullDown"></message>
		<myInfo v-if="currentIndex === 2" :pullDown.sync="pullDown"></myInfo>
    <tab-bar @changeIndex="handleChangeIndex"></tab-bar>
  </view>
</template>
<script>
import tabBar from '../../components/tabBar/index.vue'
import home from '../../components/home/index.vue'
import message from '../../components/message/index.vue'
import myInfo from '../../components/my/index.vue'
export default {
  name: 'home',
  data() {
    return {
      date: null,
			currentIndex: 0,
			pullDown: ''
    }
  },
  components: {
		tabBar,
		home,
		message,
		myInfo
  },
	watch: {
		pullDown(val) {
			if (val===''){
				uni.stopPullDownRefresh()
			}
		}
	},
	onShow() {
		// 初始化聊天
		// this.initIm()
	},
	//下拉刷新
	onPullDownRefresh() {
		this.pullDown = this.currentIndex === 0 ? 'home' : this.currentIndex === 1 ? 'message' : 'my'
		console.log(this.pullDown)
	},
	methods:{
		handleChangeIndex (index) {
			this.currentIndex = Number(index)
		},
		handleLoginLaunch() {
			console.log(1)
		}
	}
  
}
</script>
<style lang="scss" scoped>

</style>

